
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:SpawnFunction( ply, tr )	//Only Sandbox?
	if !tr.Hit then return end
	local SpawnPos = tr.HitPos + tr.HitNormal * 16

	local ent = ents.Create( "sent_gift" )
	ent:SetPos( SpawnPos )
	ent:Spawn() 
	ent:Activate()
	
	return ent
end

function ENT:Initialize()
	self.Entity:SetModel("models\effects\bday_gib0"..math.random(1,4)..".mdl")
	self.Entity:SetSkin(math.random(0,1)	//a INT, not FLOAT!
 
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )

	self.Index = self.Entity:EntIndex()
	local phys = self.Entity:GetPhysicsObject()
	if phys:IsValid() then
		phys:Wake()
	end
end

function ENT:Use(activator)
	local r=math.random(5)
	if r=0 or r=1 or r=2 then
		activator:SetHealth(activator:Health()+math.random(30))
	end else if r=3 then
		activator:Give( "melon_thrower" )
	end else if r=4 or r=5 then
		activator:EmitSound("gluttony/xmas.mp3",100,100)
	end
	self.Entity:Remove()
end
	